import QtQuick 2.12


Image{
    signal clicked()
    anchors.verticalCenter: parent.verticalCenter
    property string normalImage: "qrc:/res/ico_back_normal.svg"
    property string disableImage: "qrc:/res/ico_back_disable.svg"
    property string pressImage: "qrc:/res/ico_back_press.svg"
    property string hoverImage: "qrc:/res/ico_back_hover.svg"
    source: chooseStateParam(disableImage,pressImage,hoverImage,normalImage)
    mipmap: true
    fillMode:Image.PreserveAspectFit

    function chooseStateParam(tmp1, tmp2, tmp3, tmp4){
        if(!_mouseArea.enabled){
            return tmp1
        }
        if(_mouseArea.pressed){
            return tmp2
        }
        if(_mouseArea.containsMouse){
            return tmp3
        }
        return tmp4
    }

    MouseArea{
        id:_mouseArea
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton
        hoverEnabled: true
        onClicked: {
            parent.clicked()
        }
    }
}
